/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package practtica4;

import BBDD.GestorBBDD;
import DTO.Personaje;

/**
 *
 * @author Usuario
 */
public class V1BSimpleMuestraPers extends javax.swing.JFrame {

    /**
     * Creates new form V1BSimpleMuestraPers
     */
    GestorBBDD gestor=new GestorBBDD();
    private Personaje personaje;
    public V1BSimpleMuestraPers(Personaje personaje) {
        this.personaje=personaje;
        initComponents();
        cargarEtiquetas();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labelBio = new javax.swing.JLabel();
        botonLugMuerte = new javax.swing.JTextField();
        botonLugNac = new javax.swing.JTextField();
        botonNombre = new javax.swing.JTextField();
        labelId = new javax.swing.JLabel();
        botonFechaMuerte = new javax.swing.JTextField();
        labelFechaNac = new javax.swing.JLabel();
        botonFechaNac = new javax.swing.JTextField();
        labelFechaMuerte = new javax.swing.JLabel();
        labelLugNac = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        botonApellido = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        botonalias = new javax.swing.JTextArea();
        labelApellido = new javax.swing.JLabel();
        labelNombre = new javax.swing.JLabel();
        botonBio = new javax.swing.JTextField();
        botonId = new javax.swing.JTextField();
        labelLugMuerte = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        botoncargo = new javax.swing.JTextArea();
        botonvolver = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        labelBio.setText("Biografía");

        labelId.setText("id");

        labelFechaNac.setText("Fecha nacimiento");

        labelFechaMuerte.setText("Fecha muerte");

        labelLugNac.setText("Lugar nacimiento");

        jLabel2.setText("Cargos-Fecha inicio-Fecha fin");

        jLabel1.setText("Alias");

        botonalias.setColumns(20);
        botonalias.setRows(5);
        jScrollPane2.setViewportView(botonalias);

        labelApellido.setText("apellido");

        labelNombre.setText("nombre");

        labelLugMuerte.setText("Lugar muerte");

        botoncargo.setColumns(20);
        botoncargo.setRows(5);
        jScrollPane1.setViewportView(botoncargo);

        botonvolver.setText("Volver");
        botonvolver.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                botonvolverMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(162, 162, 162)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(botonFechaMuerte)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(botonNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                                .addGap(65, 65, 65))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(botonBio)
                                        .addComponent(botonFechaNac)
                                        .addComponent(botonApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(botonLugMuerte, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(botonLugNac, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(botonId, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(0, 105, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelFechaNac)
                            .addComponent(labelBio)
                            .addComponent(labelFechaMuerte)
                            .addComponent(labelNombre)
                            .addComponent(labelApellido)
                            .addComponent(labelId)
                            .addComponent(labelLugMuerte)
                            .addComponent(labelLugNac)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(44, 44, 44)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addGap(27, 27, 27))
            .addGroup(layout.createSequentialGroup()
                .addGap(148, 148, 148)
                .addComponent(botonvolver)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelId)
                    .addComponent(botonId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelNombre)
                    .addComponent(botonNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botonApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelApellido))
                .addGap(12, 12, 12)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelBio)
                    .addComponent(botonBio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelFechaNac)
                    .addComponent(botonFechaNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelFechaMuerte)
                    .addComponent(botonFechaMuerte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelLugNac)
                    .addComponent(botonLugNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelLugMuerte)
                    .addComponent(botonLugMuerte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE)
                .addComponent(botonvolver)
                .addGap(24, 24, 24))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botonvolverMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_botonvolverMouseClicked
     V1 v1= new V1();
        v1.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_botonvolverMouseClicked

    /**
     * @param args the command line arguments
     */
    
    private void cargarEtiquetas() {
        int id= personaje.getId();
        String id2=id+"";
        this.botonId.setText(id2);
        this.botonNombre.setText(personaje.getNombre());
        this.botonId.setEditable(false);
       this.botonNombre.setEditable(false);
       
        this.botonApellido.setText(personaje.getApellidos());
        this.botonBio.setText(personaje.getBiografia());
        String fn=personaje.getFechaNac().toString();
        String fm=personaje.getFechafMuerte().toString();
        this.botonFechaNac.setText(fn);
        this.botonFechaMuerte.setText(fm);
        this.botonLugNac.setText(personaje.getLugarNac());
        this.botonLugMuerte.setText(personaje.getLugarMuerte());
        this.botonApellido.setEditable(false);
        this.botonBio.setEditable(false);
        this.botonFechaNac.setEditable(false);
        this.botonFechaMuerte.setEditable(false);
        this.botonLugNac.setEditable(false);
        this.botonLugMuerte.setEditable(false);
        int i=0;
        String cargos="";
        while(i<personaje.getCargos().size()){
            cargos+= personaje.getCargos().get(i).getNombre()+ ","+personaje.getCargos().get(i).getFI()+","+personaje.getCargos().get(i).getFF()+'\n';
            i++;
        }
        this.botoncargo.setText(cargos);
        this.botoncargo.setEditable(false);
        String alias="";
        while(i<personaje.getAlias().size()){
            alias+= personaje.getAlias().get(i).getNombre()+'\n';
            i++;
        }
        this.botonalias.setText(alias);
        this.botonalias.setEditable(false);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Volver;
    private javax.swing.JButton Volver1;
    private javax.swing.JTextField botonApellido;
    private javax.swing.JTextField botonBio;
    private javax.swing.JTextField botonFechaMuerte;
    private javax.swing.JTextField botonFechaNac;
    private javax.swing.JTextField botonId;
    private javax.swing.JTextField botonLugMuerte;
    private javax.swing.JTextField botonLugNac;
    private javax.swing.JTextField botonNombre;
    private javax.swing.JTextArea botonalias;
    private javax.swing.JTextArea botoncargo;
    private javax.swing.JButton botonvolver;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel labelApellido;
    private javax.swing.JLabel labelBio;
    private javax.swing.JLabel labelFechaMuerte;
    private javax.swing.JLabel labelFechaNac;
    private javax.swing.JLabel labelId;
    private javax.swing.JLabel labelLugMuerte;
    private javax.swing.JLabel labelLugNac;
    private javax.swing.JLabel labelNombre;
    // End of variables declaration//GEN-END:variables
}
